'use strict';function _L(){_Ky.permissions.contains({permissions:["tabs"]},a=>{a?_xf()():_Ky.runtime.openOptionsPage()})}var _h={};function _8i(a){_Ky.system.display.getInfo(b=>{_h={};Object.defineProperty(_h,"desktop",{writable:!0,value:{x:0,y:0,w:0,h:0}});let c=0;for(let d of b)d.isEnabled&&(d.name||(d.name=`Unnamed monitor ${++c}`),_h[d.id]=d,_h.desktop=_9o(_h.desktop,_ti(d.bounds)));a&&a()})}function _Of(a){_So(_Hp,[..._hf._h].map(([,b])=>_Tj(_ti(b.bounds)).add({dpi:b.dpiX})),a)}
let _Jo=_wj(function*(a,b,c,d,e){a:for(let g of b){b=yield f=>_Ky.bookmarks.getChildren(a+"",f);if(!b)break;for(let f of b)if(!f.url&&f.title==g){a=f.id;continue a}let h={parentId:a+"",title:g,dateAdded:Date.now()};h.index=_Ep(h,b,c,d,e);({id:a}=yield f=>_Ky.bookmarks.create(h.del("dateAdded"),f))}return a});
{let a=_bo,b=(c,d)=>{c=new URL(c);d=new URL(d);let e=a(_la(c.hostname),_la(d.hostname));return e||(e=a(c.hostname,d.hostname))||(e=a(c.pathname,d.pathname))?e:(e=a(c.search,d.search))?e:a(c.hash,d.hash)};var _Ep=(c,d,e,g,h)=>{"asc"==g&&(d=d.slice().reverse());for(let f of d)if(c.id!=f.id){if(!f.url&&c.url){if("folder"==h){if("desc"==g)continue;return f.index+1}if("bkmrk"==h){if("asc"==g)continue;return f.index}}if(f.url&&!c.url){if("bkmrk"==h){if("desc"==g)continue;return f.index+1}if("folder"==h){if("asc"==
g)continue;return f.index}}if("name"==e?0<=a(c.title,f.title):"url"==e?0<=b(c.url||"aa:"+c.title,f.url||"aa:"+f.title):c.dateAdded>=f.dateAdded)return f.index+("asc"==g?1:0)}return"asc"==g?0:d.length}}
let _jo=_wj(function*(a,b,c,d,e,g,h,f){c=(yield _Jo(c,d,e,g,h))+"";if(d=yield m=>_Ky.bookmarks.getChildren(c,m)){for(let m of d)if(m.url==b){if("keep"==f)return m;if("updt"==f)return yield p=>_Ky.bookmarks.update(m.id,{title:a},p);yield p=>_Ky.bookmarks.remove(m.id,p);d=yield p=>_Ky.bookmarks.getChildren(c,p);break}var k={parentId:c,title:a,url:b,dateAdded:Date.now()};k.index=_Ep(k,d,e,g,h);return yield m=>_Ky.bookmarks.create(k.del("dateAdded"),m)}});
var _Od=(a,b=".",c=!1,d=!1)=>e=>{const g="UTF-16"==c;_So(_lf,{file:_4k[0],args:(g?"/U ":"")+_4k[1]+("keep"==d?"K":"C")+` "${a}"`,dir:b,getStdout:!!c,wideOutput:g,showWin:d?_mo:_Fk},e)},_ok=_wj(function*(a,b,c,d,e,g){c=Math.min(c||2E5,15E5);let h=b.length/c||1;for(let k=0;k<h;++k){var f=b.substr(k*c,c);f=yield _fw(_0e,{path:a,content:btoa(f),end:k+1>=h&&!g,add:d,modTime:e});"boolean"==typeof f&&(f=!f);if(f)break}return f});
{let a=0;var _i=_wj(function*(b,c,d,e=2E5){const g=a++%50+1;b=yield _fw(_gk,{path:b,id:g,charEnc:"text"==c||"charEnc"==c,minModTime:d,chunk:Math.min(e,786E3)});if(!b)return!1;b.content=_Cu(b.content)||"";"text"==c&&b.charEnc&&(b.content=_Cw(b.content,b.charEnc));return b})}{let a={},b=0;var _aa=()=>{let c=b++%100+1;delete a[c];return c},_3o=(c,d)=>{c||(c=_aa());_ih(a,c).add(d);return c},_7o=c=>a[c]||{}}
{let a=[],b=_Ow(100,function(){for(let [c,d]of a){let e=_3o(null,{tabs:d});_So(_Pj,{evtId:c|_Xs,trigInstId:e})}a=[]});var _sr=function(c,d=null){if(!(c<_f)||d){if(_ad[c]){let e=a[a.length-1];e&&e[0]==c?d&&e[1].push(d):a.push([c,d?[d]:[]]);b()}c!=_Ae&&_yu(c,d)}}}let _ee={};function _yu(a,b){"function"==typeof _cf&&_cf(a,b);if(a=_ee[a]){b=b in _sk?_sk[b].tabs.map(c=>c.id):[b];for(let [,c]of a)for(let d of b)(c[d||0]||_Qu)()}}
let _qd=function(a){let b=[];a=_7o(a).tabs;if(!_Pt(a))if(a[0]in _os)b=a;else if(a[0]in _sk)for(let c of a)b.push(..._sk[c].tabs.map(d=>d.id));return b};
var _iu=_Et(function*(a,b,c){let d=yield k=>_Ky.windows.getLastFocused(k),e=_Tj(_ti(_hf._h[_hf._Jg(d)].workArea)),g=a.width||400,h=a.height||200,f=yield k=>_Ky.windows.create({width:g,height:h,left:e.x-g/2|0,top:e.y-h/2|0,url:"file57.html",focused:!0,type:"popup",state:"normal"},k);_er("topmostWins","action").value([f.tabs[0].id],_Qu,{mode:_be});_Ky.tabs.onUpdated.addListener(function r(m,p){if(m==f.tabs[0].id&&"complete"==p.status){_Ky.tabs.onUpdated.removeListener(r);let l=_Ky.extension.getViews({windowId:f.id})[0];
l.document.title=_2f.AutoCtrl.name;l.document.body.insertAdjacentHTML("beforeend",`\n <content>\n <img src="${"AutoCtrl"}/logo48.png">\n <msg value={}>${b}</msg>\n </content>\n <actions>\n <button yes>${a.yes||"OK"}</button>\n ${!1===a.no?"":`<button no>${a.no||"Cancel"}</button>`}\n </actions>\n `);function q(){var n=_Kg(l.document.body,"offsetHeight");n&&(n=Math.max(0,l.outerHeight-l.innerHeight)+n,_Ky.windows.update(f.id,{height:n,top:l.screenY-(n-l.outerHeight)/2|0}))}for(let n of l.document.images)n.onload=
q;setTimeout(q,150);q();l.onclick=function(n){n.target.closest("button")&&(this.dialogResult=n.target.hasAttribute("yes"),_Ky.windows.remove(f.id))};l.onunload=function(){c&&this.$&&_gu(this)._pu&&c(_gu(this)._pu(this.$("msg[value]")[0]).add({answer:!!this.dialogResult}))};a.onloaded&&_gu(l)._Yj.wait()(()=>a.onloaded(l))}})});
function _ag(a){_iu({width:615,yes:"Stop waiting",no:"Keep waiting"},`\n <b>${_Qg.alias}</b> is waiting for a <act style="display: inline-block; font-size: 84%; padding:4px 6px">Run script</act> action to finish. <br>\n None of your triggers will respond while this script is still running. <hr b=2>\n This issue occurs because the script is running <b>synchronously</b> and it's taking too long to finish. <br>\n You can prevent this by running the script <b>asynchronously</b> instead, as shown below: <hr b>\n <img src="/res/runAsync.png" width=340 style="display: block; margin: 0 auto"> <hr b=6>\n \n Do you wish AutoControl to stop waiting for the script to finish? <hr b>\n <b>Stop waiting:</b> Your triggers will start responding immediately. <hr b>\n <b>Keep waiting:</b> Your triggers will not respond until the script finishes.\n `,b=>
a(b.answer))}
function _9p(a){_iu({width:590,yes:"My triggers are working fine. <br> Don't show this message again.",no:"Got it. Keep showing this message <br> if the problem continues."},`\n Apparently another program is preventing ${_Qg.alias} from detecting your triggers. <br>\n It cannot be determined automatically what program it is. <hr b=2>\n Some possibilities may include:  <hr b=2>\n <li>A third-party shortcut manager.</li>\n <li>An AutoHotKey script or program.</li>\n <li>A virtual KM switch like Synergy or Mouse Without Borders.</li>\n <li>A remote desktop utility like VNC or similar.</li>\n <li>Overly strict antivirus settings.</li>\n <hr b=4>\n To find out the cause, try disabling other programs one at a time till the issue is fixed.\n <hr b=2>\n Please report what the conflict was at the <a href="${_Ce.support}" target=_blank>support forum</a>.\n <hr b=2>\n It may as well be just a temporary problem, in which case just close this message. \n `,b=>
a(b.answer))}
function _Gs(a,b=_Qu){_iu({onloaded:c=>{c.$("key").each(function(){this.innerText=_gu(c)._jf(this.innerText)})},width:500,no:!1},`\n <import src="file84.js"></import>\n <repairTit>REPAIR COMPLETE</repairTit>\n <b>Found issue:</b> <br>\n The following keys/buttons were stuck in their PRESSED state: <hr b=4>\n <center>${a.map(c=>`<key>${c}</key>`).join("")}</center> <hr b=6>\n Your triggers won't work if there are extra keys or mouse buttons pressed unless you add a wildcard to those triggers. <hr b=3>\n If this problem keeps happening, go to the configuration page, then <u>Options</u> > <u>Advanced Options</u>, and adjust the\n "<b>Ignore synthetic input</b>" option and/or the "<b>Trigger's default wildcard</b>" option.\n <hr b=3>\n <!--\n An error report will be sent now. Please provide any additional details that can help fix the problem.\n For example: <hr b>\n What do you use those keys for? <br>\n Are they a shortcut for another program? <br>\n What happens when you press them? <hr b=2>\n <textarea name=comment maxlength=500 placeholder="Enter additional details (optional)..."></textarea>\n -->\n `,c=>
b(c.comment))}
function _Df(a){if(a&&a.tabs&&a.tabs[0].title){var b=a.tabs.reduce((c,d,e)=>d.active?e:c,0);b=Math.min(a.tabs.length-1,Math.max(0,b-2)+5);b=`\n <c missingWin>\n ${a.tabs.slice(Math.max(0,b-5),b+1).map(c=>`<tab ${c.active?"active":""}><img src="${_Tu(_7j(c))}"><tit>${_5h(c.title.substr(0,40))}</tit></tab>`).join("")}\n </c>\n `}_iu({width:590,no:!1},`\n <repairTit>REPAIR COMPLETE</repairTit>\n <b>Found issue:</b> <br>\n The ${b?"following":"currently focused"} window was misidentified as belonging to a different browser profile. <br>\n ${b||""}\n <hr b=3>\n If this problem keeps happening, do not ignore it. Try to find out what situation triggers it. <hr b=2>\n <b>For example:</b> <hr b>\n <li> Does it happen whenever the active tab in the window has a specific URL or domain?</li> \n <li> Does it happen immediately after a new browser window is created?</li> \n <li> Does it happen when you move a tab from one window to another?</li> \n <li> Does it affect the amount of browser windows currently open?</li> \n Etc... <hr b=2>\n Please report your findings at the <a href="${_Ce.support}" target=_blank>support forum</a>.\n <hr b=3>\n `)}
function _rk(a,b){return(c=_Qu,d)=>{"function"==typeof b.code&&(b.code=`(${b.code})()`);b.runAt||(b.runAt="document_start");let e=g=>c(b.allFrames?g:g[0]);0<a?_Ky.tabs.executeScript(a,b,g=>{_fy()?d&&d(_fy()):e(g||[])}):e([])}}function _6w(a,b=!1){return c=>_So(_nk,{usePrvMsPos:b}.add(a),d=>c(_Rk[d]))}
let _9k=_wj(function*(a,b=!1){let {mouse:c,win:d}=yield _fw(_zw,(b?_5y:_W)|_fo);if((b=_sk[yield _6w(null,b)])&&"devtools"!=b.type)try{const g=b.activeTab.id;yield _rk(g,{allFrames:!0,matchAboutBlank:!0,file:"file92.js"});let h=[c.x-d.x,c.y-d.y];var e=yield f=>_Ky.tabs.sendMessage(g,{viewportPoint:h,smartMode:a},{frameId:0},f);_fy("BP_to_topFrame")}catch(g){}return _Mg(e)?e:[]});
function _Kw(a){let b=a.getResponseHeader("Content-Disposition"),c=_xd(a.getResponseHeader("Content-Type"));if(b)var d=(d=b.match(/filename=(?:"([^"]+)"|([^;]+))/))&&(d[1]||d[2]);if(!d){if(d=a.responseURL.match(/^data:([^,;]*)/i))return a=_xd(d[1]),"dataUri"+(a?"."+a:"");d=_N(a.responseURL,c)}return _N(decodeURIComponent(d),c)}
function _xd(a){const b={"text/plain":"txt","audio/mpeg":"mp3","audio/webm":"weba"};a=(a||"").match(/^[^,;]*/)[0].trim().toLowerCase();if(a in b)return b[a];a=(a.match(/\/([^+]+)/)||[,""])[1].replace(/^x-/,"");return"javascript"==a?"js":5>a.length?a:""}function _ms(a){let b=new Uint8Array(a.length);for(let c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b.buffer}
function _es(a,b){+a||(a=+_Uk(a)[1]);b=_gy[a]=-1==b?!_gy[a]:!!+b;_So(_pa,{states:{[a]:b}});_pd(["LOCAL","switchStates",{},a],b,0);_Ky.contextMenus.update("binSwtch:"+a,{checked:b});return b}var _jg=()=>_qf("sections");
